articles

Home / DeveloperSection / Articles / Routing in MVC

Routing in MVC

Niraj Kumar Mishra2095 28-Aug-2017

A route is a URL pattern that is mapped together to a handler and routing is responsible for the incoming browser request for a particular MVC controller. We can also say that routing help you to define a URL structure and map the URL with the controller.

MVC4 are defined the routes in Global.asax.cs file. RegisterRoutes method define by default one route, that is given below:

Routing in MVC


This route defines the route name, which can be anything but must be unique.The default route that is pre-defined for you maps to Controller/Action/id. In the above, the MapRoute function will create a System.Web.Routing.Route instance and add it to routes collection. A route will determine whether a URL is matched with its definition and which Controller will process the URL.

You can add additional routes by copying the same line and adjusting the URL parameters and the related default values.

Routing in MVC


Updated 07-Sep-2019

Leave Comment

Comments

Liked By